package com.cyjt.operation.fragment;

import java.util.ArrayList;
import java.util.List;

import com.cyjt.operation.R;
import com.cyjt.operation.adapter.MessageManagementAdapter;
import com.cyjt.operation.bean.MessageManagement;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

/**
 * 工单消息界面，附属与消息管理Activity的ViewPager
 * 
 * @author LTP
 *
 */
public class WorkOrderMessageFragment extends Fragment {
	/** 要加载的视图 */
	private View view;
	/** 存放工单消息的ListView */
	private ListView listView_workorder_message;
	/** 工单消息的ListView的适配器 */
	private MessageManagementAdapter mMessageManagementAdapter;
	private List<MessageManagement> messageList = new ArrayList<MessageManagement>();

	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		loadWorkOrderMessage();
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		view = inflater.inflate(R.layout.fragment_workorder_message, container, false);
		initView();
		return view;
	}

	/**
	 * 控件初始化
	 */
	private void initView() {
		listView_workorder_message = (ListView) view.findViewById(R.id.listView_workorder_message);
		mMessageManagementAdapter = new MessageManagementAdapter(getActivity(),
				R.layout.list_view_item_for_message_management, messageList);
		listView_workorder_message.setAdapter(mMessageManagementAdapter);
	}

	/**
	 * 加载工单消息数据
	 */
	private void loadWorkOrderMessage() {
		// TODO Auto-generated method stub
		MessageManagement messageManagement1 = new MessageManagement();
		messageManagement1.setWorkOrderMessage("工单消息1");
		messageList.add(messageManagement1);
		MessageManagement messageManagement2 = new MessageManagement();
		messageManagement2.setWorkOrderMessage("工单消息2");
		messageList.add(messageManagement2);
		MessageManagement messageManagement3 = new MessageManagement();
		messageManagement3.setWorkOrderMessage("工单消息3");
		messageList.add(messageManagement3);
	}
}
